﻿@inherits BaseComponent

<div class="kui-app">
    @if (!IsHome)
    {
        <div class="kui-app-nav">
            @if (!string.IsNullOrWhiteSpace(App?.CurrentMenu?.BackUrl))
            {
                <span class="back" @onclick="e=>App?.Back()">
                    <Icon Type="left" Theme="outline" />
                    <span>返回</span>
                </span>
            }
            @App?.CurrentMenu?.Name
        </div>
    }
    <div class="@pageClass">
        @ChildContent
    </div>
    @if (IsTab)
    {
        <AppTab Items="Config.AppMenus" />
    }
</div>

@code {
    private bool IsHome => Context.Url == "/app";
    private bool IsTab => Context.Current?.Target == "Tab";
    private string pageClass => CssBuilder.Default("kui-app-page")
                                          .AddClass("nav", !IsHome)
                                          .AddClass("tab", IsTab)
                                          .BuildClass();

    [Parameter] public RenderFragment ChildContent { get; set; }
}